<!DOCTYPE html>
<!--[if IE 6]><html class="ie lt-ie8"><![endif]-->
<!--[if IE 7]><html class="ie lt-ie8"><![endif]-->
<!--[if IE 8]><html class="ie ie8"><![endif]-->
<!--[if IE 9]><html class="ie ie9"><![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">

  <!-- Start of Baidu Transcode -->
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta name="applicable-device" content="pc,mobile">
  <meta name="MobileOptimized" content="width"/>
  <meta name="HandheldFriendly" content="true"/>
  <meta name="mobile-agent" content="format=html5;url=https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
  <!-- End of Baidu Transcode -->

    <meta name="description"  content="本文是我学习Python爬虫的笔记,一直想要再学一门语言来扩展自己的知识面,看了看各种语言主要使用的方向,最后决心还是来搞一搞Python.Python给我的第一印象就是语法简洁,格式另类还有各种库的支持,就喜欢这么有个性的语言为了以后深入的学习爬虫,事先肯定是先把语法学了一遍,下面是我实现的一个小爬虫,可以通过百度图库利用关键字来搜索图片并下载 工具准备: 不要多想,挑个IDE吧,我用的是...">

  <meta name="360-site-verification" content="604a14b53c6b871206001285921e81d8" />
  <meta property="wb:webmaster" content="294ec9de89e7fadb" />
  <meta property="qc:admins" content="104102651453316562112116375" />
  <meta property="qc:admins" content="11635613706305617" />
  <meta property="qc:admins" content="1163561616621163056375" />
  <meta name="google-site-verification" content="cV4-qkUJZR6gmFeajx_UyPe47GW9vY6cnCrYtCHYNh4" />
  <meta name="google-site-verification" content="HF7lfF8YEGs1qtCE-kPml8Z469e2RHhGajy6JPVy5XI" />
  <meta http-equiv="mobile-agent" content="format=html5; url=https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">

  <!-- Apple -->
  <meta name="apple-mobile-web-app-title" content="简书">

    <!--  Meta for Smart App Banner -->
  <meta name="apple-itunes-app" content="app-id=888237539, app-argument=jianshu://notes/4205846">
  <!-- End -->

  <!--  Meta for Twitter Card -->
  <meta content="summary" property="twitter:card">
  <meta content="@jianshucom" property="twitter:site">
  <meta content="Python爬虫-搜索并下载图片" property="twitter:title">
  <meta content="本文是我学习Python爬虫的笔记,一直想要再学一门语言来扩展自己的知识面,看了看各种语言主要使用的方向,最后决心还是来搞一搞Python.Python给我的第一印象就是语法简洁,格式另类还有各种库的支持,就喜欢这么有个性的语言为了以后深入的学习爬虫,事先肯定是先把语法学了一遍,下面是我实现的一个小爬虫,可以通过百度图库利用关键字来搜索图片并下载 工具准备: 不要多想,挑个IDE吧,我用的是PyCharm(免费的~嗯,今年刚刚免费的) 打开PyCharm的设置(找找在哪,我都是直接commond+,的,如果你有commond键的话)在Project下选择Project Interpret..." property="twitter:description">
  <meta content="https://www.jianshu.com/p/f66e9ecd6afb" property="twitter:url">
  <!-- End -->

  <!--  Meta for OpenGraph -->
  <meta property="fb:app_id" content="865829053512461">
  <meta property="og:site_name" content="简书">
  <meta property="og:title" content="Python爬虫-搜索并下载图片">
  <meta property="og:type" content="article">
  <meta property="og:url" content="https://www.jianshu.com/p/f66e9ecd6afb">
  <meta property="og:description" content="本文是我学习Python爬虫的笔记,一直想要再学一门语言来扩展自己的知识面,看了看各种语言主要使用的方向,最后决心还是来搞一搞Python.Python给我的第一印象就是语法简洁,格式另类还有各...">
  <!-- End -->

  <!--  Meta for Facebook Applinks -->
  <meta property="al:ios:url" content="jianshu://notes/4205846" />
  <meta property="al:ios:app_store_id" content="888237539" />
  <meta property="al:ios:app_name" content="简书" />

  <meta property="al:android:url" content="jianshu://notes/4205846" />
  <meta property="al:android:package" content="com.jianshu.haruki" />
  <meta property="al:android:app_name" content="简书" />
  <!-- End -->


    <title>Python爬虫-搜索并下载图片 - 简书</title>

  <meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="8v25/J5UakFPXaNjAEFo5DjlSqrvhP0zBzQq5MXYqkHXtidLItUoHLDHPJ/oBd0S/B3X5oTU645GvD1aBfKREg==" />

  <link rel="stylesheet" media="all" href="//cdn2.jianshu.io/assets/web-00c42afb57693e779815.css" />
  
  <link rel="stylesheet" media="all" href="//cdn2.jianshu.io/assets/web/pages/notes/show/entry-26b7d612b78d3be06fb9.css" />

  <link href="//cdn2.jianshu.io/assets/favicons/favicon-03411b154a430b85d807b4366489c21122fb983a38f3d7ca926f882e6367b13e.ico" rel="icon">
      <link rel="apple-touch-icon-precomposed" href="//cdn2.jianshu.io/assets/apple-touch-icons/57-a6f1f1ee62ace44f6dc2f6a08575abd3c3b163288881c78dd8d75247682a4b27.png" sizes="57x57" />
      <link rel="apple-touch-icon-precomposed" href="//cdn2.jianshu.io/assets/apple-touch-icons/72-fb9834bcfce738fd7b9c5e31363e79443e09a81a8e931170b58bc815387c1562.png" sizes="72x72" />
      <link rel="apple-touch-icon-precomposed" href="//cdn2.jianshu.io/assets/apple-touch-icons/76-49d88e539ff2489475d603994988d871219141ecaa0b1a7a9a1914f4fe3182d6.png" sizes="76x76" />
      <link rel="apple-touch-icon-precomposed" href="//cdn2.jianshu.io/assets/apple-touch-icons/114-24252fe693524ed3a9d0905e49bff3cbd0228f25a320aa09053c2ebb4955de97.png" sizes="114x114" />
      <link rel="apple-touch-icon-precomposed" href="//cdn2.jianshu.io/assets/apple-touch-icons/120-1bb7371f5e87f93ce780a5f1a05ff1b176828ee0d1d130e768575918a2e05834.png" sizes="120x120" />
      <link rel="apple-touch-icon-precomposed" href="//cdn2.jianshu.io/assets/apple-touch-icons/152-bf209460fc1c17bfd3e2b84c8e758bc11ca3e570fd411c3bbd84149b97453b99.png" sizes="152x152" />

  <!-- Start of 访问统计 -->
    <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?0c0e9d9b1e7d617b3e6842e85b9fb068";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>

  <!-- End of 访问统计 -->
</head>

  <body lang="zh-CN" class="reader-black-font">
    <!-- 全局顶部导航栏 -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="width-limit">
    <!-- 左上方 Logo -->
    <a class="logo" href="/"><img src="//cdn2.jianshu.io/assets/web/nav-logo-4c7bbafe27adc892f3046e6978459bac.png" alt="Nav logo" /></a>

    <!-- 右上角 -->
      <!-- 未登录显示登录/注册/写文章 -->
      <a class="btn write-btn" target="_blank" href="/writer#/">
        <i class="iconfont ic-write"></i>写文章
</a>      <a class="btn sign-up" href="/sign_up">注册</a>
      <a class="btn log-in" href="/sign_in">登录</a>

    <!-- 如果用户登录，显示下拉菜单 -->

    <div id="view-mode-ctrl">
    </div>
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu" aria-expanded="false">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <div class="collapse navbar-collapse" id="menu">
        <ul class="nav navbar-nav">
            <li class="tab ">
              <a href="/">
                <span class="menu-text">首页</span><i class="iconfont ic-navigation-discover menu-icon"></i>
</a>            </li>
            <li class="tab ">
              <a id="web-nav-app-download-btn" class="app-download-btn" href="/apps?utm_medium=desktop&amp;utm_source=navbar-apps"><span class="menu-text">下载App</span><i class="iconfont ic-navigation-download menu-icon"></i></a>
            </li>
          <li class="search">
            <form target="_blank" action="/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="&#x2713;" />
              <input type="text" name="q" id="q" value="" autocomplete="off" placeholder="搜索" class="search-input" />
              <a class="search-btn" href="javascript:void(null)"><i class="iconfont ic-search"></i></a>
</form>          </li>
        </ul>
      </div>
    </div>
  </div>
</nav>

    
<div class="note">
  <a target="_blank" href="/apps/download?utm_source=sbc" id="web-note-ad-fixed"><span class="close">&times;</span></a>
  <div class="post">
    <div class="article">
        <h1 class="title">Python爬虫-搜索并下载图片</h1>

        <!-- 作者区域 -->
        <div class="author">
          <a class="avatar" href="/u/3e8081b02399">
            <img src="//upload.jianshu.io/users/upload_avatars/1594222/22acc2fa4b4a?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96" alt="96" />
</a>          <div class="info">
            <span class="name"><a href="/u/3e8081b02399">SSBun</a></span>
            <!-- 关注用户按钮 -->
            <div props-data-classes="user-follow-button-header" data-author-follow-button></div>
            <!-- 文章数据信息 -->
            <div class="meta">
              <!-- 如果文章更新时间大于发布时间，那么使用 tooltip 显示更新时间 -->
                <span class="publish-time" data-toggle="tooltip" data-placement="bottom" title="最后编辑于 2017.12.03 06:08">2016.06.02 18:39*</span>
              <span class="wordage">字数 1180</span>
            </div>
          </div>
          <!-- 如果是当前作者，加入编辑按钮 -->
        </div>

        <!-- 文章内容 -->
        <div data-note-content class="show-content">
          <div class="show-content-free">
            <p><strong>本文是我学习Python爬虫的笔记,一直想要再学一门语言来扩展自己的知识面,看了看各种语言主要使用的方向,最后决心还是来搞一搞Python.Python给我的第一印象就是语法简洁,格式另类还有各种库的支持,就喜欢这么有个性的语言<sub>为了以后深入的学习爬虫,事先肯定是先把语法学了一遍,下面是我实现的一个小爬虫,可以通过百度图库利用关键字来搜索图片并下载</sub></strong></p>
<h3>工具准备:</h3>
<ul>
<li>不要多想,挑个IDE吧,我用的是<a href="https://link.jianshu.com?t=https://www.jetbrains.com/pycharm/" target="_blank" rel="nofollow">PyCharm</a>(免费的~嗯,今年刚刚免费的)</li>
<li>打开PyCharm的设置(找找在哪,我都是直接commond+,的,如果你有commond键的话)<strong>在Project下选择Project Interpreter然后点击左下角的加号,在输入框中输入requests,收索后安装</strong>,其实还有很多其他的安装方法,使用pip,在终端中敲入那些代码,然后还有什么其他的东西,不过还是这样比较偷懒(其实前面的坑我都爬过了)</li>
<li>Python为最新版,2.7应该也没问题,并未使用Scrapy爬虫框架,也没有使用lxml,仅仅使用re正则和requests网络请求</li>
</ul>
<h3>re和requests用法</h3>
<ul>
<li>
<h5>re正则</h5>
</li>
</ul>
<p>re就是正则,主要是用来解析数据的,当我们拿到网页的数据时需要从中提取处我们想要的数据,正则匹配就时其中的一个方法,至于正则的写法,这里就不在多讲,想看的在这里<a href="https://link.jianshu.com?t=http://deerchao.net/tutorials/regex/regex.htm" target="_blank" rel="nofollow">正则表达式30分钟入门教程</a>,而re的常用使用手法可以在我的这篇文章里了解<a href="https://www.jianshu.com/p/4177ab305bf4" target="_blank">Python爬虫-re(正则表达式)模块常用方法</a>,这里我们主要使用其<code>re.findall("正则表达式","被匹配数据",匹配限制(例如:忽略大小写))</code></p>
<ul>
<li>
<h5>requests网络请求</h5>
</li>
</ul>
<p>requests的封装异常的强大,几乎可以做任何形式的网络请求,这里我们只是使用了其最简单的get请求<code>requests.get("url",timeout=5)</code>,详细了解,可以看一下(<a href="https://link.jianshu.com?t=http://blog.csdn.net/iloveyin/article/details/21444613" target="_blank" rel="nofollow">requests快速入门</a>)</p>
<h3>具体的步骤</h3>
<ul>
<li><p>首先是想清楚想要做什么,你想要获取什么数据(没有目标哪来的动力啊),这里我们是想要通过百度图片来后去图片链接及内容,我想要搜索关键字,并可以指定搜索的数据量,选择是否保存及保存的路径~</p></li>
<li><p>需求有了,就要去分析要爬去的网页结构了,看一下我们的数据都在哪,我们这次要扒去的图片来自百度图片</p></li>
<li>
<p>首先进入百度图库,你所看见的页面当向下滑动的时候可以不停的刷新,这是一个动态的网页,而我们可以选择更简单的方法,就是点击网页上方的传统翻页版本</p>
<br>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 441px;">
<div class="image-container-fill" style="padding-bottom: 63.07000000000001%;"></div>
<div class="image-view" data-width="1370" data-height="864"><img data-original-src="//upload-images.jianshu.io/upload_images/1594222-5667d5bcfc60ef0d.png" data-original-width="1370" data-original-height="864" data-original-format="image/png" data-original-filesize="940942"></div>
</div>
<div class="image-caption">QQ20160602-0@2x.png</div>
</div>
</li>
<li>
<p>接下来就是我们熟悉的翻页界面,你可以点击第几页来获取更多的图片</p>
<br>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 448px;">
<div class="image-container-fill" style="padding-bottom: 64.11%;"></div>
<div class="image-view" data-width="1906" data-height="1222"><img data-original-src="//upload-images.jianshu.io/upload_images/1594222-806dd571907aadfd.png" data-original-width="1906" data-original-height="1222" data-original-format="image/png" data-original-filesize="2528993"></div>
</div>
<div class="image-caption">QQ20160602-1@2x.png</div>
</div>
</li>
<li>
<p>点击鼠标的右键可以查看网页的源代码,大概就是这个样子的,我们get下来的数据,就是这个啦,我们需要在这里面找到<strong>各个图片的链接</strong>和<strong>下一页的链接</strong>,然而有点懵,这么多的数据,我们想要的在哪里呢?<br>
</p>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 462px;">
<div class="image-container-fill" style="padding-bottom: 66.01%;"></div>
<div class="image-view" data-width="2030" data-height="1340"><img data-original-src="//upload-images.jianshu.io/upload_images/1594222-44a773d6638a7022.png" data-original-width="2030" data-original-height="1340" data-original-format="image/png" data-original-filesize="857062"></div>
</div>
<div class="image-caption">QQ20160602-2@2x.png</div>
</div>
<p></p>
</li>
<li>
<p>不着急,我们可以通过浏览器的开发者工具来查看网页的元素,我用的是Chrome,打开Developer Tools来查看网页样式,当你的鼠标从结构表中划过时会实时显示此段代码所对应的位置区域,我们可以通过此方法,快速的找到图片所对应的位置:</p>
<br>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 445px;">
<div class="image-container-fill" style="padding-bottom: 63.61%;"></div>
<div class="image-view" data-width="2336" data-height="1486"><img data-original-src="//upload-images.jianshu.io/upload_images/1594222-90c77c1d53792f8e.png" data-original-width="2336" data-original-height="1486" data-original-format="image/png" data-original-filesize="2069191"></div>
</div>
<div class="image-caption">QQ20160602-3@2x.png</div>
</div>
<br>
<p>找到了一张图片的路径和下一页的路径,我们可以在源码中搜索结果找到他们的位置,并分析如何书写正则来获取信息:</p>
<br>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 448px;">
<div class="image-container-fill" style="padding-bottom: 64.07000000000001%;"></div>
<div class="image-view" data-width="2260" data-height="1448"><img data-original-src="//upload-images.jianshu.io/upload_images/1594222-df6ffb1612333460.png" data-original-width="2260" data-original-height="1448" data-original-format="image/png" data-original-filesize="797108"></div>
</div>
<div class="image-caption">QQ20160602-4@2x.png</div>
</div>
</li>
<li><p>所有的数据都分析完毕了,这个时候就要开始写我们的爬虫了,看了这么久,竟然一句代码都没有:</p></li>
</ul>
<pre><code>import requests #首先导入库
import  re
</code></pre>
<pre><code>然后设置默认配置
</code></pre>
<pre><code>MaxSearchPage = 20 # 收索页数
CurrentPage = 0 # 当前正在搜索的页数
DefaultPath = "/Users/caishilin/Desktop/pictures" # 默认储存位置
NeedSave = 0 # 是否需要储存
</code></pre>
<pre><code>图片链接正则和下一页的链接正则
</code></pre>
<pre><code>def imageFiler(content): # 通过正则获取当前页面的图片地址数组
          return re.findall('"objURL":"(.*?)"',content,re.S)
def nextSource(content): # 通过正则获取下一页的网址
          next = re.findall('&lt;div id="page"&gt;.*&lt;a href="(.*?)" class="n"&gt;',content,re.S)[0]
          print("---------" + "http://image.baidu.com" + next) 
          return next
</code></pre>
<pre><code>爬虫主体
</code></pre>
<pre><code>def spidler(source):
          content = requests.get(source).text  # 通过链接获取内容
          imageArr = imageFiler(content) # 获取图片数组
          global CurrentPage
          print("Current page:" + str(CurrentPage) + "**********************************")
          for imageUrl in imageArr:
              print(imageUrl)
              global  NeedSave
              if NeedSave:  # 如果需要保存保存
                 global DefaultPath
                 try:                
                      picture = requests.get(imageUrl,timeout=10) # 下载图片并设置超时时间,如果图片地址错误就不继续等待了
                 except:                
                      print("Download image error! errorUrl:" + imageUrl)                
                      continue            
                 pictureSavePath = DefaultPath + imageUrl.replace('/','') # 创建图片保存的路径
                 fp = open(pictureSavePath,'wb') # 以写入二进制的方式打开文件            fp.write(picture.content)
                 fp.close()
           else:   
                global MaxSearchPage
                if CurrentPage &lt;= MaxSearchPage:
                    if nextSource(content):
                        CurrentPage += 1                                         
                        spidler("http://image.baidu.com" + nextSource(content)) # 爬取完毕后通过下一页地址继续爬取
</code></pre>
<pre><code>爬虫的开启方法
</code></pre>
<pre><code>def  beginSearch(page=1,save=0,savePath="/users/caishilin/Desktop/pictures/"): # (page:爬取页数,save:是否储存,savePath:默认储存路径)
          global MaxSearchPage,NeedSave,DefaultPath
          MaxSearchPage = page
          NeedSave = save
          DefaultPath = savePath
          key = input("Please input you want search 
          StartSource = "http://image.baidu.com/search/flip?tn=baiduimage&amp;ie=utf-8&amp;word=" + str(key) + "&amp;ct=201326592&amp;v=flip" # 分析链接可以得到,替换其`word`值后面的数据来收索关键词
          spidler(StartSource)
</code></pre>
<pre><code> 调用开启的方法就可以通过关键词搜索图片了
</code></pre>
<pre><code>beginSearch(page=1,save=0)
</code></pre>
<h3>小结</h3>
<p>** 因为对Python的理解还不是特别的深入,所以代码比较繁琐,相比较爬虫框架Scrapy来说,直接使用reqests和re显得并不是特别的酷,但是这是学习理解爬虫最好的方式,接下来我会陆陆续续将我学习爬虫框架Scrapy的过程写下来,有错误的地方请指正~**</p>

          </div>
        </div>
    </div>

    <!-- 连载目录项 -->

    <!-- 打赏文章、购买文章、购买连载 -->

      <div class="show-foot">
        <a class="notebook" href="/nb/4521477">
          <i class="iconfont ic-search-notebook"></i>
          <span>Python</span>
</a>        <div class="copyright" data-toggle="tooltip" data-html="true" data-original-title="转载请联系作者获得授权，并标注“简书作者”。">
          © 著作权归作者所有
        </div>
        <div class="modal-wrap" data-report-note>
          <a id="report-modal">举报文章</a>
        </div>
      </div>

      <!-- 文章底部作者信息 -->
        <div class="follow-detail">
          <div class="info">
            <a class="avatar" href="/u/3e8081b02399">
              <img src="//upload.jianshu.io/users/upload_avatars/1594222/22acc2fa4b4a?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96" alt="96" />
</a>            <div props-data-classes="user-follow-button-footer" data-author-follow-button></div>
            <a class="title" href="/u/3e8081b02399">SSBun</a>
            
          </div>
            <div class="signature">给时间一点时间～</div>
        </div>

    <div class="meta-bottom">
      <div class="btn like-group"></div>
      <div class="share-group">
        <a class="share-circle" data-action="weixin-share" data-toggle="tooltip" data-original-title="分享到微信">
          <i class="iconfont ic-wechat"></i>
        </a>
        <a class="share-circle" data-action="weibo-share" data-toggle="tooltip" href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f=&#39;http://v.t.sina.com.cn/share/share.php?appkey=1881139527&#39;,u=z||d.location,p=[&#39;&amp;url=&#39;,e(u),&#39;&amp;title=&#39;,e(t||d.title),&#39;&amp;source=&#39;,e(r),&#39;&amp;sourceUrl=&#39;,e(l),&#39;&amp;content=&#39;,c||&#39;gb2312&#39;,&#39;&amp;pic=&#39;,e(p||&#39;&#39;)].join(&#39;&#39;);function%20a(){if(!window.open([f,p].join(&#39;&#39;),&#39;mb&#39;,[&#39;toolbar=0,status=0,resizable=1,width=440,height=430,left=&#39;,(s.width-440)/2,&#39;,top=&#39;,(s.height-430)/2].join(&#39;&#39;)))u.href=[f,p].join(&#39;&#39;);};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,&#39;&#39;,&#39;&#39;,&#39;&#39;, &#39;推荐 @用户5673676632 的文章《Python爬虫-搜索并下载图片》（ 分享自 @简书 ）&#39;,&#39;https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=reader_share&amp;utm_source=weibo&#39;,&#39;页面编码gb2312|utf-8默认gb2312&#39;));" data-original-title="分享到微博">
          <i class="iconfont ic-weibo"></i>
        </a>
          <a class="share-circle" data-toggle="tooltip" href="http://cwb.assets.jianshu.io/notes/images/4205846/weibo/image_66012024cb17.jpg" target="_blank" data-original-title="下载长微博图片">
            <i class="iconfont ic-picture"></i>
          </a>
        <a class="share-circle more-share" tabindex="0" data-toggle="popover" data-placement="top" data-html="true" data-trigger="focus" href="javascript:void(0);" data-content='
          <ul class="share-list">
            <li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r=&#39;http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=&#39;+e(&#39;https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=reader_share&amp;utm_source=qzone&#39;)+&#39;&amp;title=&#39;+e(&#39;推荐 SSBun 的文章《Python爬虫-搜索并下载图片》&#39;),x=function(){if(!window.open(r,&#39;qzone&#39;,&#39;toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=600&#39;))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-zone"></i><span>分享到QQ空间</span></a></li>
            <li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r=&#39;https://twitter.com/share?url=&#39;+e(&#39;https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=reader_share&amp;utm_source=twitter&#39;)+&#39;&amp;text=&#39;+e(&#39;推荐 SSBun 的文章《Python爬虫-搜索并下载图片》（ 分享自 @jianshucom ）&#39;)+&#39;&amp;related=&#39;+e(&#39;jianshucom&#39;),x=function(){if(!window.open(r,&#39;twitter&#39;,&#39;toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=600&#39;))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-twitter"></i><span>分享到Twitter</span></a></li>
            <li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r=&#39;https://www.facebook.com/dialog/share?app_id=483126645039390&amp;display=popup&amp;href=https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=reader_share&amp;utm_source=facebook&#39;,x=function(){if(!window.open(r,&#39;facebook&#39;,&#39;toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330&#39;))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-facebook"></i><span>分享到Facebook</span></a></li>
            <li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r=&#39;https://plus.google.com/share?url=&#39;+e(&#39;https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=reader_share&amp;utm_source=google_plus&#39;),x=function(){if(!window.open(r,&#39;google_plus&#39;,&#39;toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330&#39;))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-google"></i><span>分享到Google+</span></a></li>
            <li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:&#39;&#39;,r=&#39;http://www.douban.com/recommend/?url=&#39;+e(&#39;https://www.jianshu.com/p/f66e9ecd6afb?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=reader_share&amp;utm_source=douban&#39;)+&#39;&amp;title=&#39;+e(&#39;Python爬虫-搜索并下载图片&#39;)+&#39;&amp;sel=&#39;+e(s)+&#39;&amp;v=1&#39;,x=function(){if(!window.open(r,&#39;douban&#39;,&#39;toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330&#39;))location.href=r+&#39;&amp;r=1&#39;};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()"><i class="social-icon-sprite social-icon-douban"></i><span>分享到豆瓣</span></a></li>
          </ul>
        '>更多分享</a>
      </div>
    </div>
      <a id="web-note-ad-1" target="_blank" href="/apps/download?utm_source=nbc"><img src="//cdn2.jianshu.io/assets/web/web-note-ad-1-10f08e404d3887d2d45a4bc8f1831403.png" alt="Web note ad 1" /></a>
    <div id="vue_comment"></div>
  </div>

  <div class="vue-side-tool" props-data-props-show-qr-code="0"></div>
</div>
<div class="note-bottom">
  <div class="js-included-collections"></div>
  <div data-vcomp="recommended-notes" data-lazy="1.5" data-note-id="4205846"></div>
  <!-- 相关文章 -->
  <div class="seo-recommended-notes">

        <div class="note have-img">
          <a class="cover" target="_blank" href="/p/0bfd0c48457f?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <img src="//upload-images.jianshu.io/upload_images/3471485-fe45807df6553906.png?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240" alt="240" />
</a>          <a class="title" target="_blank" href="/p/0bfd0c48457f?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">爬虫（1）--- Python网络爬虫二三事</a>
          <p class="description">1 前言 作为一名合格的数据分析师，其完整的技术知识体系必须贯穿数据获取、数据存储、数据提取、数据分析、数据挖掘、数据可视化等各大部分。在此作为初出茅庐的数据小白，我将会把自己学习数据科学过程中遇到的一些问题记录下来，以便后续的查阅，同时也希望与各路同学一起交流、一起进步。...</p>
          <a class="author" target="_blank" href="/u/51c2a335b8a1?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/3471485/617d85f4b304?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">whenif</span>
</a>        </div>

        <div class="note have-img">
          <a class="cover" target="_blank" href="/p/e52e85a3ce48?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <img src="//upload-images.jianshu.io/upload_images/8707342-d2149d14ad8c24c3?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240" alt="240" />
</a>          <a class="title" target="_blank" href="/p/e52e85a3ce48?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">一小时入门 Python 3 网络爬虫</a>
          <p class="description">声明：本文讲解的实战内容，均仅用于学习交流，请勿用于任何商业用途！ 一、前言 强烈建议：请在电脑的陪同下，阅读本文。本文以实战为主，阅读过程如稍有不适，还望多加练习。 本文的实战内容有： 网络小说下载（静态网站） 优美壁纸下载（动态网站） 爱奇艺VIP视频下载 二、网络爬虫...</p>
          <a class="author" target="_blank" href="/u/ebb2bac1bfba?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/8707342/0bfdc331-9936-48e0-80dd-244a74df7655.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">Bruce_Szh</span>
</a>        </div>

        <div class="note ">
                    <a class="title" target="_blank" href="/p/5c12b5eb6be5?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">Python 系列（二）- 收藏集 - 掘金</a>
          <p class="description">Python 函数式编程入门教程 - 后端 - 掘金本文为作者原创，转载请先与作者联系。同发于博客园和 SegmentFault专栏 Functional Programming 引言 Functional Programming(函数式编程)的概念最早起源于LISP，由约...</p>
          <a class="author" target="_blank" href="/u/5fc9b6410f4f?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/120495/6220dd63-bf1a-40a8-8ccc-e364a5c90f13.png?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">掘金官方</span>
</a>        </div>

        <div class="note have-img">
          <a class="cover" target="_blank" href="/p/d8a59076d031?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <img src="//upload-images.jianshu.io/upload_images/1335883-f6c9bfbe7309a75a.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240" alt="240" />
</a>          <a class="title" target="_blank" href="/p/d8a59076d031?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">零基础三天学会Python爬虫 -- 龙头</a>
          <p class="description">最近iOS方面没有开发任务, 老板给了我两周的时间学习爬虫. 期间踩了无数的坑. 终于算是可以在爬虫方面有所小成, 在学习阶段很感谢各种大神的技术文章对我的帮助. 可是如果你是小白的话, 这些技术文章的阅读难度会比较大. 可能会导致在学习阶段在环境配置, IDE选择, 初始...</p>
          <a class="author" target="_blank" href="/u/5e0e96eb6573?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/1335883/63f28410dc58?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">Pusswzy</span>
</a>        </div>

        <div class="note ">
                    <a class="title" target="_blank" href="/p/047b4dd3f911?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">Python爬虫学习手册</a>
          <p class="description">爬虫文章 in 简书程序员专题： like:128-Python 爬取落网音乐 like:127-【图文详解】python爬虫实战——5分钟做个图片自动下载器 like:97-用Python写一个简单的微博爬虫 like:87-爬虫抓取拉勾网职位需求关键词，并生成统计图 l...</p>
          <a class="author" target="_blank" href="/u/324165d32970?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/6857392/ce6a656e-d3c2-42a5-9205-eeb0797522dd.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">喜欢吃栗子</span>
</a>        </div>

        <div class="note ">
                    <a class="title" target="_blank" href="/p/09015eee626a?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">还是他.</a>
          <p class="description">特别想一个人是什么感觉. 就是在夜里你看见关于他的消息. 知道了他最近的状况. 笑了笑. 发现他还是他. 也只能是他. 你还爱他.</p>
          <a class="author" target="_blank" href="/u/b3aa05e86e25?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/5041781/1980dff4-148b-4b56-a2dd-538e472b0138?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">雯八岁</span>
</a>        </div>

        <div class="note have-img">
          <a class="cover" target="_blank" href="/p/e49affbe1cf1?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <img src="//upload-images.jianshu.io/upload_images/2573655-22b87001e2183383?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240" alt="240" />
</a>          <a class="title" target="_blank" href="/p/e49affbe1cf1?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">这是为什么呢？LOL中的女生都喜欢玩辅助和AD？</a>
          <p class="description">在我认识的女生，在LOL的女生中，特别喜欢玩中路和上路，还有打野的女生基本上……有，但是不多。 但是相对的呢？玩辅助和玩AD的女生就非常的多。 基本上的女生，我所认识的女生，她们在玩LOL的时候玩的英雄大部分都是AD和辅助。 我就不禁的纳闷了，这是为什么呢？ 这是为什么呢？...</p>
          <a class="author" target="_blank" href="/u/d8fff3f86efb?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/2573655/1e707669b7ab?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">黄铜刀</span>
</a>        </div>

        <div class="note ">
                    <a class="title" target="_blank" href="/p/1c0ee1408692?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">2017-08-31</a>
          <p class="description">记挂之深，不能入事</p>
          <a class="author" target="_blank" href="/u/b4ae21772ee7?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//cdn2.jianshu.io/assets/default_avatar/12-aeeea4bedf10f2a12c0d50d626951489.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">我不想为你带来困扰</span>
</a>        </div>

        <div class="note have-img">
          <a class="cover" target="_blank" href="/p/c125e1e6cd5d?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <img src="//upload-images.jianshu.io/upload_images/1900807-77c1ca821903cd8c.JPG?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240" alt="240" />
</a>          <a class="title" target="_blank" href="/p/c125e1e6cd5d?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">生活工作育儿，思维导图都有用武之地</a>
          <p class="description">我们是否有过这样的体验？工作千头万绪，待处理事项一大堆，会议中需要表达观点思路却还没理顺；回到家面对满屋狼藉，两口子为谁拖地都可能吵起来；育儿理念的分歧也能导致一顿争执；孩子越长大越不愿意与大人交流想法，作业拖拖拉拉，学习主动性下降；去shopping咦怎么把这个给忘了。。...</p>
          <a class="author" target="_blank" href="/u/113a116c3bba?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/1900807/4925c0383023.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">睦妈是也</span>
</a>        </div>

        <div class="note ">
                    <a class="title" target="_blank" href="/p/f049616233c1?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes&amp;utm_source=recommendation">小小育儿经~</a>
          <p class="description">以下是今年年初一次家长交流分享会上的分享内容，简单整理出来，再次显摆显摆~~ 我们家有两个儿子，大儿子已经十岁了，正在上小学五年级，小儿子两岁了，正在茁壮成长。我们两口子都没有上过有关孩子教育的专业课程，相关的书籍也没有详读过。但就目前大儿子的状态看，我们自己还是深感满意并...</p>
          <a class="author" target="_blank" href="/u/31f6f411b669?utm_campaign=maleskine&amp;utm_content=user&amp;utm_medium=seo_notes&amp;utm_source=recommendation">
            <div class="avatar">
              <img src="//upload.jianshu.io/users/upload_avatars/4443306/e3b1cdda-aff0-47ea-bd38-a4f395a4d32e?imageMogr2/auto-orient/strip|imageView2/1/w/48/h/48" alt="48" />
            </div>
            <span class="name">神七公</span>
</a>        </div>
  </div>
</div>

    <script type="application/json" data-name="page-data">{"user_signed_in":false,"locale":"zh-CN","os":"windows","read_mode":"day","read_font":"font2","note_show":{"is_martin_user":false,"is_author":false,"is_following_author":false,"is_liked_note":false,"follow_state":0,"uuid":"c4a11721-b346-4ea4-94f0-85b2e6434bd1"},"note":{"id":4205846,"slug":"f66e9ecd6afb","user_id":1594222,"notebook_id":4521477,"commentable":true,"likes_count":18,"views_count":1751,"public_wordage":1180,"comments_count":6,"total_rewards_count":0,"is_author":false,"paid_type":"free","paid_content_accessible":false,"author":{"nickname":"SSBun","total_wordage":39513,"followers_count":258,"total_likes_count":596}}}</script>
    
    <script src="//cdn2.jianshu.io/assets/babel-polyfill-2bec152a537b07763933.js" crossorigin="anonymous"></script>
    <script src="//cdn2.jianshu.io/assets/web-base-cb61bace309af62e3f64.js" crossorigin="anonymous"></script>
<script src="//cdn2.jianshu.io/assets/web-dd671d4ce3826300aa83.js" crossorigin="anonymous"></script>
    
    <script src="//cdn2.jianshu.io/assets/web/pages/notes/show/entry-fa3b41ef80e4a60a463d.js" crossorigin="anonymous"></script>
    <script>
  (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
          bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
          bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
  })();
</script>

  </body>
</html>
